"""
# Definition for a Node.
class Node(object):
    def __init__(self, val=None, children=None):
        self.val = val
        self.children = children
"""

class Solution(object):
    def levelOrder(self, root):
        """
        :type root: Node
        :rtype: List[List[int]]
        """
        out = []
        if not root:
            return out
        now = [root]
        while now:
            next_list = []
            now_out = []
            for node in now:
                now_out.append(node.val)
                for item in node.children:
                    next_list.append(item)
            out.append(now_out)
            now = next_list
        return out
